package s_004_Bean_Automatic_Assembly.bean;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

/**
 * 会返回 3 个构造器。最终执行的，还是参数最多的那个构造器。
 *
 * @see AbstractAutowireCapableBeanFactory#createBeanInstance(String, RootBeanDefinition, Object[])
 * return autowireConstructor(beanName, mbd, ctors, args);
 */
@Component
public class Car {

    private ApplicationContext applicationContext;
    private BeanFactory beanFactory;

    @Autowired(required = false)
    public Car(ApplicationContext applicationContext) {
        this.applicationContext = applicationContext;
    }

    @Autowired(required = false)
    public Car(ApplicationContext applicationContext, BeanFactory beanFactory) {
        this.applicationContext = applicationContext;
        this.beanFactory = beanFactory;
    }

    public Car() {
        System.out.println("car constructor...");
    }
}